package homework06;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        System.out.println("请输入一个字符串：");
        //键盘录入字符串
        Scanner scanner = new Scanner(System.in);
        String next = scanner.next();
        //将字符串转换成字符串数组
        char[] chars = next.toCharArray();
        //创建map集合用来
        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < chars.length; i++) {
            if (map.containsKey(chars[i])) {
                map.put((chars[i]), map.get(chars[i] )+ 1);
            } else {
                map.put(chars[i], 1);
            }
        }
        System.out.println(map);
        

    }
}
